<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>增加省代理商</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.js"></script>
		<script src="__PUBLIC__/static/js/area/area.js" ></script>
	</head>

	<body>
		<form id='layui-form' class="layui-form update_form" >
			<div class="layui-form-item">
				<label class="layui-form-label" style="width: 115px;">选择省份</label>
				<div class="layui-input-block" style="float: left; margin-right: 20px; margin-left: 0;">
					<select id="s_province" required lay-verify="required" name="province"></select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label" style="width: 115px;">手机号</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="mobile" required lay-verify="required" placeholder="手机号" autocomplete="off" class="layui-input"> (作为登录账号)
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label" style="width: 115px;">姓名</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="user_name" required lay-verify="required" placeholder="姓名" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label" style="width: 115px;">登录密码</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="password" required lay-verify="required" placeholder="登录密码" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
					<label class="layui-form-label" style="width: 115px;">分佣比例</label>
					<div class="layui-input-block update_shurk">
							<input type="number" style="width: 40%;float: left;" id="oem_bili" name="oem_bili" required lay-verify="required" value=""  placeholder="分佣占充值比例" autocomplete="off" class="layui-input" >
							<span style="width: 10%;height:38px;line-height:38px;text-align:center;">%</span><p></p>
					</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label" style="width: 115px;">状态</label>
				<div class="layui-input-block">
					<input type="radio" name="status" value="1" title="正常" checked>
					<input type="radio" name="status" value="2" title="冻结">
				</div>
			</div>
			<div class="layui-form-item update_btnbox">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
		<script>
			layui.use('form', function() {
				var form = layui.form;

				
				//监听提交
				form.on('submit(demo1)', function(data){
					if($('#oem_bili').val()>65){
						layer.msg('省代理的分佣不能超过平台限制的65%,请请示上级！', {time:3000});
						return false;
					}

					if($('#oem_bili').val()<0){
						layer.msg('请输入正确的分佣比例', {time:1500});
						return false;
					}
					
					if($('#s_province').val()==0){
						layer.msg('请选择省份', {time:1500});
						return false;
					}
					add_account();
				    return false;
				});
				
			});

			_init_area();
			var Gid = document.getElementById;

			var showArea = function() {

				Gid('show').innerHTML = "<h3>省" + Gid('s_province').value 

			}
			//提交表单
			function add_account() {
				
				$.ajax({
					type: "post",
					url: "{:url('accounts/add_agency')}",
					data: $('.layui-form').serialize(), //表单数据
					success: function(data) {
						if(data.code == 200) {
							layer.msg('添加成功', {
								icon: 1,
								time: 1500 //2秒关闭（如果不配置，默认是3秒）
							}, function() {
								window.parent.location.reload();
								var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
								parent.layer.close(index);
							});
						} else {
							layer.msg(data.msg); //保存成功提示
						}
					},
					error: function(data) {
						var a = data;
					}
				});

			}
		</script>
	</body>

</html>